package csc.fresher.bankservice;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.Validator;

import csc.fresher.dao.HistoryDAO;
import csc.fresher.dao.RoleDAO;
import csc.fresher.dao.StatusDAO;
import csc.fresher.dao.UserInfoDAO;
import csc.fresher.domain.History;
import csc.fresher.domain.Role;
import csc.fresher.domain.Status;
import csc.fresher.domain.UserInfo;
import csc.fresher.domain.json.UserTemp;
import csc.fresher.hashpassword.HashPasswordSHA;

@Service
public class BankServiceImpl implements BankService {

	@Autowired
	private UserInfoDAO userInfoDAO;
	
	@Autowired
	private HistoryDAO historyDAO;
	
	@Autowired
	private RoleDAO roleDAO;
	
	@Autowired
	private StatusDAO statusDAO;
	
	@Autowired
	private HashPasswordSHA hashPasswordSHA;
	
	@Override
	@Transactional
	public UserInfo getUserInfo(String loginId) {
		return userInfoDAO.getUserInfo(loginId);
	}
	
	@Override
	@Transactional
	public UserTemp getUserTest(String loginId) {
		return userInfoDAO.getUserTest(loginId);
	}

	@Override
	@Transactional
	public List<UserInfo> userInfos() {
		return userInfoDAO.userInfos();
	}

	@Override
	@Transactional
	public boolean save(UserInfo userInfo) {
		userInfoDAO.save(userInfo);
		return true;
	}
	
	@Override
	@Transactional
	public boolean update(UserInfo userInfo) {
		userInfoDAO.update(userInfo);
		return true;
	}
	
	@Override
	@Transactional
	public boolean checkLoginId(String loginId) {
		return userInfoDAO.checkLoginId(loginId);
	}

	@Override
	@Transactional
	public List<UserInfo> userNomal() {
		return userInfoDAO.userNomal();
	}

	@Override
	@Transactional
	public List<UserInfo> usernew() {
		return userInfoDAO.usernew();
	}

	@Override
	@Transactional
	public List<UserInfo> useractive() {
		return userInfoDAO.useractive();
	}

	@Override
	@Transactional
	public List<UserInfo> userdisable() {
		return userInfoDAO.userdisable();
	}
	
	@Override
	@Transactional
	public UserInfo getUserAuthentication(String loginId) {
		return userInfoDAO.getUserAuthentication(loginId);
	}

	@Override
	@Transactional
	public int addHistory(History history) {
		int id = historyDAO.addHistory(history);
		return id;
	}

	@Override
	@Transactional
	public History getHistory(int id) {
		return historyDAO.getHistory(id);
	}

	@Override
	@Transactional
	public boolean saveOrUpdate(History history) {
		historyDAO.saveOrUpdate(history);
		return true;
	}

	@Override
	@Transactional
	public List<History> histories() {
		return historyDAO.histories();
	}
	
	@Override
	@Transactional
	public Role getRole(int roleid) {
		Role role = roleDAO.getRole(roleid);
		return role;
	}
	
	@Override
	@Transactional
	public Status getStatus(int statusid) {
		Status status = statusDAO.getStatus(statusid);
		return status;
	}

	@Override
	public String hashPasswordSHA(String password) {
		return hashPasswordSHA.hashPasswordSHA(password);
	}

}
